package ua.keeper.query;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;


public class DbOpenHelper extends SQLiteOpenHelper
{
	private static final int DB_VERSION = 1;
	private static final String DB_NAME = "query8";
	private static final String CREATE_TABLE_TP = "CREATE TABLE tp_list (title varchar)";
	private static final String CREATE_TABLE_CLIENT = "CREATE TABLE clients (id_ integer, day integer, title varchar, code varchar)";
	private static final String CREATE_TABLE_GOODS = "CREATE TABLE goods (id_ integer, title varchar, price double)";
	private static final String CREATE_TABLE_SETTINGS = "CREATE TABLE settings (tp_name varchar)";
	private static final String CREATE_TABLE_QUERY_H = "CREATE TABLE query_h (id_ integer, client integer)";
	private static final String CREATE_TABLE_QUERY_D = "CREATE TABLE query_d (id_ integer, head integer, goods integer, q integer)";
	
    /*****************************************************************************************/
	public DbOpenHelper(Context context)
	{
		super(context, DB_NAME, null, DB_VERSION);
		Log.i("DataBase", "Created");
	}
	
    /*****************************************************************************************/
	@Override
	public void onCreate(SQLiteDatabase sqLiteDatabase)
	{
		Log.i("DataBase", CREATE_TABLE_TP);
		sqLiteDatabase.execSQL(CREATE_TABLE_TP);
		/**/
		sqLiteDatabase.execSQL("INSERT INTO tp_list (title) VALUES ('Иванов А.Е.')");
		sqLiteDatabase.execSQL("INSERT INTO tp_list (title) VALUES ('Греченко Е.В.')");
		sqLiteDatabase.execSQL("INSERT INTO tp_list (title) VALUES ('Абрамов К.А.')");
		sqLiteDatabase.execSQL("INSERT INTO tp_list (title) VALUES ('Власов Д.Ю.')");
		sqLiteDatabase.execSQL("INSERT INTO tp_list (title) VALUES ('Соколова Т.В.')");
		/**/
		Log.i("DataBase", CREATE_TABLE_CLIENT);
		sqLiteDatabase.execSQL(CREATE_TABLE_CLIENT);
		/**/
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (1, 1, 'Синапс-плюс', '111001')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (2, 1, 'ЛИА ЛТД Абсалют', '111002')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (3, 1, 'ООО Ремик', '111003')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (4, 1, 'Лелека', '111004')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (5, 1, 'ЧП Конюхова', '111005')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (6, 1, 'ЧП Смирнова', '111006')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (7, 1, 'ЧП Кондратюк', '111007')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (8, 1, 'ЧП МиниМаркет', '111008')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (9, 1, 'ЧП Ларек', '111009')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (10, 1, 'ООО Бокри', '111010')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (11, 1, 'Центральный Рынок', '111011')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (12, 2, 'Абсолют Перевальск', '111012')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (13, 2, 'Абсолют Стаханов', '111013')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (14, 0, 'ЧП Валенок', '111014')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (15, 0, 'Магазин Ольховский', '111015')");
		sqLiteDatabase.execSQL("INSERT INTO clients (id_, day, title, code) VALUES (16, 0, 'с-т Калина', '111016')");
		/**/
		Log.i("DataBase", CREATE_TABLE_GOODS);
		sqLiteDatabase.execSQL(CREATE_TABLE_GOODS);
		/**/
		sqLiteDatabase.execSQL("INSERT INTO goods (id_, title, price) VALUES (1, 'Немирофф водка 0.5', 25.21)");
		sqLiteDatabase.execSQL("INSERT INTO goods (id_, title, price) VALUES (2, 'Немирофф водка 0.7', 32.80)");
		sqLiteDatabase.execSQL("INSERT INTO goods (id_, title, price) VALUES (3, 'Хлебный Дар водка 0.5', 21.00)");
		sqLiteDatabase.execSQL("INSERT INTO goods (id_, title, price) VALUES (4, 'Хлебный Дар водка 0.7', 26.34)");
		sqLiteDatabase.execSQL("INSERT INTO goods (id_, title, price) VALUES (5, 'Чумак Паста 200гр', 5.50)");
		sqLiteDatabase.execSQL("INSERT INTO goods (id_, title, price) VALUES (6, 'Торчин майонез 72% 300гр', 6.80)");
		sqLiteDatabase.execSQL("INSERT INTO goods (id_, title, price) VALUES (7, 'Сок Сандора Томат 1л', 9.15)");
		sqLiteDatabase.execSQL("INSERT INTO goods (id_, title, price) VALUES (8, 'Сок Сандора Вишня 1л', 9.04)");
		/**/
		Log.i("DataBase", CREATE_TABLE_SETTINGS);
		sqLiteDatabase.execSQL(CREATE_TABLE_SETTINGS);
		/**/
		sqLiteDatabase.execSQL("INSERT INTO settings (tp_name) VALUES ('Костенко Д.Ю.')");
		/**/
		Log.i("DataBase", CREATE_TABLE_QUERY_H);
		sqLiteDatabase.execSQL(CREATE_TABLE_QUERY_H);
		sqLiteDatabase.execSQL("INSERT INTO query_h (id_, client) VALUES (1, 3)");
		sqLiteDatabase.execSQL("INSERT INTO query_h (id_, client) VALUES (2, 3)");
		sqLiteDatabase.execSQL("INSERT INTO query_h (id_, client) VALUES (3, 3)");
		sqLiteDatabase.execSQL("INSERT INTO query_h (id_, client) VALUES (4, 4)");
		/**/
		Log.i("DataBase", CREATE_TABLE_QUERY_D);
		sqLiteDatabase.execSQL(CREATE_TABLE_QUERY_D);
		sqLiteDatabase.execSQL("INSERT INTO query_d (id_, head, goods, q) VALUES (1, 1, 1, 5)");
		sqLiteDatabase.execSQL("INSERT INTO query_d (id_, head, goods, q) VALUES (2, 1, 4, 10)");
		sqLiteDatabase.execSQL("INSERT INTO query_d (id_, head, goods, q) VALUES (3, 3, 3, 9)");
		sqLiteDatabase.execSQL("INSERT INTO query_d (id_, head, goods, q) VALUES (4, 3, 4, 4)");
		sqLiteDatabase.execSQL("INSERT INTO query_d (id_, head, goods, q) VALUES (5, 3, 2, 7)");
		sqLiteDatabase.execSQL("INSERT INTO query_d (id_, head, goods, q) VALUES (6, 4, 1, 1)");
	}
	
    /*****************************************************************************************/
	@Override
	public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) 
	{
	}
}